package org.kealinghornets.jchuah.buttons;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;


public class MainActivity extends ActionBarActivity {


    public void checkVictory() {
        View LeftStar = findViewById(R.id.LeftStar);
        View MiddleStar = findViewById(R.id.MiddleStar);
        View RightStar = findViewById(R.id.RightStar);
        if (LeftStar.getVisibility() == View.INVISIBLE && MiddleStar.getVisibility() == View.INVISIBLE && RightStar.getVisibility() == View.INVISIBLE) {
            Toast.makeText(this, "You have won a useless game! You just wasted more of your worthless life!", Toast.LENGTH_LONG).show();
            startActivity (new Intent(this, Level2Activity.class));
        }
    }
    public void toggleVisibility (int id) {
        View Star;

        Star = findViewById(id);

        if (Star.getVisibility()==View.VISIBLE) {
            Star.setVisibility(View.INVISIBLE);
        }else{
            Star.setVisibility(View.VISIBLE);
        }
    }
    public void onLeftButtonPush(View view) {
        Log.d("Yourface" , "THE BUTTON IS BEING PUSHED!!1!1!one!!eleven11!");
        Toast.makeText(this, "This button is 4.2% more interesting than the average grandmother.", Toast.LENGTH_SHORT).show();
        toggleVisibility(R.id.LeftStar);
        checkVictory();
    }

    public void onMidButtonPush(View view) {
        Log.d("Yourface" , "THE OTHER BUTTON IS BEING PUSHED!!!11!!!ONELE!!VEN");
        Toast.makeText(this, "This is the boring middle button.", Toast.LENGTH_SHORT) .show();
        toggleVisibility(R.id.MiddleStar);
        checkVictory();
    }
   public void onRightButtonPush(View view) {
       Log.d("Yourface" , "ANOTHER BUTTON IS BEING PUSHED!!!ELKEVEN!!O1N1E1");
           Toast.makeText(this, "This button is killing you slowly.", Toast.LENGTH_SHORT) .show();
            toggleVisibility(R.id.RightStar);
       checkVictory();
   }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
